<?php 	
	include("head.php");
	include_once("paging_function.php");
?>
<?php

/////////////////////////////////PAGING /////////////////

 	if(isset($_GET['page']) && $_GET['page']!='')

		{

		

			$page = $_GET['page'];

		}

	else

		{
		  	$page = 0;
		}

$limit=$adminpagelimit;

/////////////////////////////////////////////////////////////////	

?>

<?php

////////////////////////////////////////////    Block_---- DELETE  ///////////

if(isset($_POST['Submit']))

{

	$del=$_POST['del'];

	$no=count($del);

	if($no>0)

	{

	for($i=0;$i<$no;$i++)

	{

	   mysql_query("DELETE FROM ".FEEDBACK."  WHERE feedbackId= '".$del[$i]."' ");	   

	}

	echo '<script>window.location="feedback.php?dlt=1"</script>';

	}
	$block=$_POST['count_UPDATE'];
	if($_POST['count_UPDATE']>0)
	{
	for($no_up=0; $no_up<$block;$no_up++)
	{
	if(isset($_POST['block'.$no_up]))
	{
	 mysql_query("UPDATE ".FEEDBACK."  SET status='N' WHERE feedbackId='".$_POST['block'.$no_up]."'");
	 
	}else
	{
	 mysql_query("UPDATE ".FEEDBACK." SET status='Y' WHERE feedbackId='".$_POST['block_hid'.$no_up]."'");
	  
	}
	}
	echo '<script>window.location="feedback.php?page='.$_GET['page'].'&loop='.$_GET['loop'].'&start='.$_GET['start'].'&blk=1"</script>';
	}

	
}



?>


<?php

	$search="SELECT * FROM ".FEEDBACK." ORDER BY date  DESC";
	
	

	$search=$search." limit $page,$limit";

	$searchquery=mysql_query($search) or die('error1'.mysql_error());

?>

<fieldset>

<legend class="LEGEND">FEEDBACK  MANAGEMENT</legend>

  <table width="100%" border="0" cellspacing="0" cellpadding="3">
	
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="3" >
	
		<?php
		
		if((isset($_REQUEST['action'])=='edit'))
		
		{
		
		$editquery=mysql_query("SELECT * FROM ".FEEDBACK." WHERE`feedbackId`='".$_REQUEST['feedbackId']."'");
		
		$fetch=mysql_fetch_array($editquery);		
		?>	
		<tr><td colspan="7" id="edit_section" style="display:;">
	
			<fieldset>
			<legend class="LEGEND"> Feed Back </legend>
	
			<form name="edit" action="" method="POST" onSubmit="return check();" >
	
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
	
				<tr>				
					<td width="17%" align="left" id="admin_text">Contact Name</td>				
					<td width="2%" align="left">::</td>				
					<td width="81%" align="left"><input name="name" type="text" value="<?php echo $fetch['name'];?>" size="42" readonly=""></td>
				</tr>				
				
				<tr>
				
				<td width="17%" align="left" id="admin_text">Email</td>
				
				<td width="2%" align="left">::</td>
				
				<td width="81%" align="left"><input name="name22" type="text" value="<?php echo $fetch['email'];?>" size="42" readonly=""></td>
				</tr>
				<tr>
				
				<td width="17%" align="left" id="admin_text">Date</td>
				
				<td width="2%" align="left">::</td>
				
				<td width="81%" align="left"><input name="name22" type="text" value="<?php echo $fetch['date'];?>" size="42" readonly=""></td>
				</tr>
				
				<tr>
				
				<td width="17%" align="left" id="admin_text">Message</td>
				
				<td width="2%" align="left">::</td>
				
				<td width="81%" align="left"><textarea  name="message"  cols="40" rows="7" readonly="readonly"><?php  echo stripslashes($fetch['feedback']);?></textarea></td>
				</tr>	
				<tr>	
				<td align="center">&nbsp;</td>	
				<td align="center">&nbsp;</td>	
				<td align="left">&nbsp;	
				<input type="button" value="Close" name="close_frm" id="close_frm" onClick="window.location='feedback.php';" /></td>
				</tr>
				</table>
			</form>
			</fieldset>
	
	<?php } ?>
	
	</td></tr>	
		<tr>
	
		<td height="40" colspan="7" align="left" valign="middle" style="color:#FF0000">
			<p>
			<?php 
			if(isset($_GET['blk']) && $_GET['blk']==1)
			{
			echo $msg1="Value Blocked/Unblocked Successfully!!!";
			}
			if(isset($_GET['dlt']) && $_GET['dlt']==1)
			{
			echo $msg1="Value Deleted Successfully!!!";
			}
			if(isset($_GET['inst']) && $_GET['inst']==1)
			{
			echo $msg1="Value insert Successfully!!!";
			}
			if(isset($_GET['updt']) && $_GET['updt']==1)
			{
			echo $msg1="Value UPDATE Successfully!!!";
			}
			?>
			</p>
			<p>&nbsp;</p></td>
		</tr>	
		<?php
		if(mysql_num_rows($searchquery)>0)	
		{
		?><form name="form_admin_management" action="" method="post">	
		<tr bgcolor="#6F8DBC">		
			<td width="3%" height="28" style="color:#ffffff;font-size:12px;"><strong>S.No</strong></td>		
			<td valign="middle" style="color:#ffffff;font-size:12px;"><strong>Feed Back</strong></td>		
			<td width="17%" valign="middle" style="color:#ffffff;font-size:12px;" align="center"><strong>User Email</strong></td>
			<td width="16%" valign="middle" style="color:#ffffff;font-size:12px;" align="center"><strong>Date</strong></td>
			<td width="10%" valign="middle" style="color:#ffffff;font-size:12px;" align="center"><strong>Details</strong></td>		
			<td width="13%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Blocked/Unblock</strong></td>
			<td width="7%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
		</tr>	
		<?php 	
		$count=0;	
		$sno=1;	
		$loop=0;
		
		while($searcharray=mysql_fetch_array($searchquery))
		
		{	
		$loop++;	
		if($loop == 1)	
		$bgcolor = "#F0F0FF";	
		else	
		$bgcolor = "#CCCCFF";	
		?>	
		<tr bgcolor="<?php echo $bgcolor; ?>">		
			<td height="32" style="color:#000000;font-size:12px;"><strong><?php echo $sno+$_GET['page'];//echo $searcharray['usercode']; ?></strong></td>		
			<td align="left" valign="middle" style="color:#000000;font-size:12px;"><?php $rest =$searcharray['feedback'];
			echo substr("$rest",0,15);?>
		    ....</td>		
			<td align="left" valign="middle" style="color:#000000;font-size:12px;" ><?php echo $searcharray['email'];?></td>
			<td align="center" valign="middle" style="color:#000000;font-size:12px;" ><?php echo $searcharray['date'];?></td>
			<td valign="middle" style="color:#000000;font-size:12px;" align="center"><a href="feedback.php?action=edit&feedbackId=<?php echo $searcharray['feedbackId'];?>" ><img src="images/edit_icon.gif" border="0"/></a></td>		
			<td align="center" valign="middle"><input type="checkbox" name="block<?php echo $count; ?>" value="<?php echo $searcharray['feedbackId']; ?>" <?php if($searcharray['status']=='N') echo "checked";?>>
			<input type="hidden" name="block_hid<?php echo $count; ?>" value="<?php echo $searcharray['feedbackId'];?>"></td>		
			<td align="center" valign="middle"><input type="checkbox" name="del[]" value="<?php echo $searcharray['feedbackId'];?>">			</td>
		</tr>	
		<?php 	
		$count++;	
		$sno++;	
		if($loop == 2)	
		{	
		$loop = 0;	
		}	
		
		}
		
		?>	
		<tr>		
		<td colspan="6">&nbsp;</td>		
		<td colspan="3" align="right"><input type="hidden" name="count_UPDATE" value="<?php echo $count; ?>">		
		<input type="submit" name="Submit" value="Update"></td>
		</tr>	
		<tr>		
		<td colspan="9" align="center" style="color:#FF0000"><?php echo paging($search,$page,$limit,'',$param);?></td>
		</tr>	
		<?php		
		}		
		else	
		{
		?>	
		<tr bgcolor="#6F8DBC">		
			<td style="color:#ffffff;font-size:12px;"><strong>S.No</strong></td>		
			<td style="color:#ffffff;font-size:12px;"><strong>Feed Back</strong></td>		
			<td width="17%" align="center" style="color:#ffffff;font-size:12px;"><strong><strong>User   Email </strong></strong></td>
			<td width="16%" align="center" style="color:#ffffff;font-size:12px;"><strong>Date</strong></td>
			<td width="10%" style="color:#ffffff;font-size:12px;" align="center"><strong>Details</strong></td>		
			<td width="13%" align="center" style="color:#ffffff;font-size:12px;"><strong>Status</strong></td>		
			<td align="center" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
		</tr>	
		<tr>		
			<td colspan="10" align="left"  class="DISPLAYMESSAGES">&nbsp;&nbsp;&nbsp;No Result Found!</td>
		</tr>
		
		<?php
		
		}
		?></form>
	</table>
		</td>
	</tr>
	
  </table>

</fieldset>

<?php 



include("foot.php");?>